package com.atguigu.tingshu.comment.api;

import com.atguigu.tingshu.comment.service.CommentService;
import com.atguigu.tingshu.common.login.GuiguLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.vo.comment.CommentVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "专辑评论管理")
@RestController
@RequestMapping("/api/comment")
@Slf4j
public class CommentApiController {

	@Autowired
	private CommentService commentService;

	/**
	 * 保存评论
	 * @param commentVo
	 * @return
	 */
	@GuiguLogin
	@PostMapping("save")
	public Result save(@RequestBody CommentVo commentVo){
		commentService.save(commentVo);
		return Result.ok();
	}

	/**
	 * 分页条件查询评论列表
	 * @param albumId
	 * @param trackId
	 * @param page
	 * @param size
	 * @return
	 */
	@GuiguLogin
	@GetMapping(value = "/findCommentPage/{albumId}/{trackId}/{page}/{size}")
	public Result findCommentPage(@PathVariable(value = "albumId") Long albumId,
								  @PathVariable(value = "trackId") Long trackId,
								  @PathVariable(value = "page") Integer page,
								  @PathVariable(value = "size") Integer size){
		return Result.ok(commentService.findCommentPage(albumId, trackId, page, size));
	}
}

